package com.ttc.group2.videochat.utils;

import android.content.Context;
import android.content.SharedPreferences;

public class Preferences {

	private static final String PREF_NAME = "_pref_video_chat";
	private static final String USERNAME = "_user_name";

	/** GCM **/
	public static final String PREF_PUSH_MESSAGE_USER_ID = "push_user_id";
	public static final String PREF_PUSH_MESSAGE_NEED_TO_OPEN_DIALOG = "push_need_to_open_dialog";
	public static final String PREF_PUSH_MESSAGE_DIALOG_ID = "push_dialog_id";

	private static SharedPreferences getSettings(Context context) {
		return context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
	}

	public static void setUserName(Context context, String userName) {
		SharedPreferences.Editor editor = getSettings(context).edit();
		editor.putString(USERNAME, userName);
		editor.commit();
	}

	public static String getUserName(Context context) {
		return getSettings(context).getString(USERNAME, null);
	}

	public static void setUserId(Context context, int user_id) {
		SharedPreferences.Editor editor = getSettings(context).edit();
		editor.putInt(PREF_PUSH_MESSAGE_USER_ID, user_id);
		editor.commit();
	}

	public static int getUserId(Context context) {
		return getSettings(context).getInt(PREF_PUSH_MESSAGE_USER_ID, 0);
	}

	public static void setDialogId(Context context, String dialog_id) {
		SharedPreferences.Editor editor = getSettings(context).edit();
		editor.putString(PREF_PUSH_MESSAGE_DIALOG_ID, dialog_id);
		editor.commit();
	}

	public static int getDialogId(Context context) {
		return getSettings(context).getInt(PREF_PUSH_MESSAGE_DIALOG_ID, 0);
	}

	public static void setNeedToOpenDialog(Context context, boolean value) {
		SharedPreferences.Editor editor = getSettings(context).edit();
		editor.putBoolean(PREF_PUSH_MESSAGE_NEED_TO_OPEN_DIALOG, false);
		editor.commit();
	}

	public static boolean getNeedToOpenDialog(Context context) {
		return getSettings(context).getBoolean(
				PREF_PUSH_MESSAGE_NEED_TO_OPEN_DIALOG, false);
	}
}
